import { Client } from "./mod.ts";

/**
 * PayloadUser represents a user in hook payload
 */
export interface PayloadUser {
  name: string;
  email: string;
  username: string;
}

/**
 * PayloadCommit represents a commit in hook payload
 */
export interface PayloadCommit {
  id: string;
  message: string;
  url: string;
  author: PayloadUser;
  committer: PayloadUser;
  added: string[];
  removed: string[];
  modified: string[];
  timestamp: string;
}

/**
 * Branch represents a repository branch.
 */
export interface Branch {
  name: string;
  commit: PayloadCommit;
}

/**
 * Branch API endpoints
 */
export class BranchAPI {
  constructor(private client: Client) {}

  /**
   * List branches of a repository
   */
  async listBranches(owner: string, repo: string): Promise<Branch[]> {
    return await this.client.doRequest<Branch[]>(
      "GET", 
      `/repos/${owner}/${repo}/branches`
    );
  }

  /**
   * Get a specific branch of a repository
   */
  async getBranch(owner: string, repo: string, branch: string): Promise<Branch> {
    return await this.client.doRequest<Branch>(
      "GET", 
      `/repos/${owner}/${repo}/branches/${branch}`
    );
  }
} 